Splunk MINT SDK for Android (Legacy)

Splunk MINT SDK for Android Developer Guide

Splunk MINT is no longer available for purchase as of January 29, 2021. Customers who have already been paying to ingest and process MINT data in Splunk Enterprise will continue to receive support until December 31, 2021, which is End of Life for all MINT products: App, Web Service (Management Console), SDK and Add-On.

Report LogCat output

LogCat is the Android logging system that lets you collect and view system debug output. To investigate how your app and user devices affect each other, you can instruct your app to send LogCat output with a crash report.

Note If you enable LogCat logging, only unhandled exceptions will contain the LogCat output.
  1. To send LogCat output with your exceptions, add the following line to your app's AndroidManifest.xml file:
  2. <uses-permission android:name="android.permission.READ_LOGS" />
    

    Splunk MINT uses this permission to read the LogCat output.

    Note The READ_LOGS permission instructs the app to report the entire LogCat output, including passwords and other sensitive data that your app collects. Take care when storing and sharing this data.

  3. To enable LogCat logging, use the enableLogging method as follows:
  4. Mint.enableLogging(true);
    
  5. Optionally, to restrict the number of lines or to set a filter string for log output, use the setLogging method with additional parameters:
    • setLogging(lines)
    • setLogging(filter)
    • setLogging(lines, filter)

    The following code shows examples of using the setLogging method with different filter expressions:

    // Log the last 100 messages
    Mint.setLogging(100);
    
    // Log all messages with priority level "warning" and higher, on all tags
    Mint.setLogging("*:W");
    
    // Log the latest 100 messages with priority level "warning" and higher,
    // on all tags
    Mint.setLogging(100, "*:W");
    
    // Log all messages from the ActivityManager at priority "Info" or above,
    // all log messages with tag "MyApp", with priority "Debug" or above:
    Mint.setLogging(400, "ActivityManager:I MyApp:D *:S");
    

    By default, Splunk MINT sends the last 500 lines with no filter. Splunk MINT filtering uses the same filtering mechanism as LogCat. For more information about filter expressions, see Filtering Log Output on the Android Developers website.

To examine the LogCat output:

  1. Go to the Errors dashboard in Splunk MINT Management Console and click an error.
  2. On the error details page, click Error Instances above the table.
  3. In the View Logs column, click the icon to view a log file for a particular error instance.


Example AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.splunk.mint.example"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_LOGS"
/>
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    <application
        ...
    </application>
</manifest>


Example code

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // TODO: Update with your API key
    Mint.initAndStartSession(this.getApplication(), "YOUR_API_KEY");

    // Enable logging
    Mint.enableLogging(true);

    // Log last 100 messages
    Mint.setLogging(100);

    setContentView(R.layout.main);

    // Continue with your code
}
Last modified on 28 January, 2019
Report network calls manually   Report debugging messages

This documentation applies to the following versions of Splunk MINT SDK for Android (Legacy): 5.2.x


Was this topic useful?







You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters